package cn.hackcloud.mutithread.mutilthread.waitnotifyinsert;

public class DBTools {
	private volatile boolean prevIsA = false;

	public synchronized void backupA() {
		try {
			if (prevIsA == true) {
				wait();
			}
			for (int i = 0; i < 5; i++) {
				System.out.println("★★★★★");

			}
			prevIsA = true;
			notifyAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public synchronized void backupB() {
		try {
			if (prevIsA == false) {
				wait();
			}
			for (int i = 0; i < 5; i++) {
				System.out.println("☆☆☆☆☆");

			}
			prevIsA = false;
			notifyAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
